﻿// Shader-Based-Image-Processing (SBIP)
// http://code.google.com/p/sbip/
//
// Copyright © Frank Nagl, 2009-2011
// admin@franknagl.de
//
namespace SBIP.Helper.DataTypes
{
    using System.Drawing;

    /// <summary> Container of three byte components (X, Y, Z).  </summary>
    public struct Byte3
    {
        /// <summary>X-component.</summary>
        public byte X { get; set; }
        /// <summary>Y-component.</summary>
        public byte Y { get; set; }
        /// <summary>Z-component.</summary>
        public byte Z { get; set; }

        /// <summary>
        /// Initializes a new instance of the <see cref="Byte3"/> struct.
        /// </summary>
        /// <param name="x">The x component.</param>
        /// <param name="y">The y component.</param>
        /// <param name="z">The z component.</param>
        public Byte3(byte x, byte y, byte z) : this()
        {
            X = x;
            Y = y;
            Z = z;
        }

        /// <summary>
        /// Returns the X- and Y-component as <see cref="Point"/>.
        /// </summary>
        /// <returns>The X- and Y-component as <see cref="Point"/>.</returns>
        public Byte2 ToByte2()
        {
            return new Byte2(X, Y);
        }

        /// <summary>
        /// Returns the X-, Y-, and Z-component as <see cref="Point3"/>.
        /// </summary>
        /// <returns>
        /// The X-, Y-, and Z-component as <see cref="Point3"/>.</returns>
        public Point3 ToPoint3()
        {
            return new Point3(X, Y, Z);
        }

        /// <summary>
        /// Returns the X-, Y-, and Z-component as <see cref="Color"/>.
        /// </summary>
        /// <returns>
        /// The X-, Y-, and Z-component as <see cref="Color"/>.</returns>
        public Color ToColor()
        {
            return Color.FromArgb(X, Y, Z);
        }
    }
}
